Skip to content

payload variant to omit unused binders#24

Open
MdSadiqMd wants to merge 1 commit intohyperpush-org:mainfrom
MdSadiqMd:sadiq/payload-variant-to-omit-unused-binders
Open

payload variant to omit unused binders#24
MdSadiqMd wants to merge 1 commit intohyperpush-org:mainfrom
MdSadiqMd:sadiq/payload-variant-to-omit-unused-binders

Conversation

@MdSadiqMd
Copy link
Copy Markdown
Contributor

Closes #22

Summary

Allow payload-bearing constructor patterns to omit unused binders in pattern matching. Users can now write Ok -> ... and Err -> ... instead of requiring Ok(_) -> ... and Err(_) -> ... when the payload is intentionally ignored.

Changes:

  • Type checker (mesh-typeck/src/infer.rs): Treat bare payload-bearing constructors as having wildcard arguments for all fields; recognize uppercase identifiers with function types as constructors and return their result type
  • Code generator (mesh-codegen/src/mir/lower.rs): Generate MirPattern::Constructor with wildcard patterns for all variant fields when no explicit binder is provided
  • Tests: Added exhaustiveness and e2e tests covering Ok/Err, Some/None, and mixed bare/explicit forms

This eliminates repetitive placeholder noise in Result/Option-heavy code while maintaining exhaustiveness checking and type safety.

Verification

# Run new exhaustiveness tests
cargo test --package mesh-typeck --test exhaustiveness_integration -- test_bare
# Result: 3/3 tests passed (bare Ok/Err, bare Some, mixed forms)

# Run new e2e tests
cargo test --package meshc --test e2e -- e2e_bare_payload_constructor
# Result: 2/2 tests passed (Err arm, Ok arm execution)

# Verify no regressions in exhaustiveness checking
cargo test --package mesh-typeck --test exhaustiveness_integration
# Result: 19/19 tests passed (all existing + new tests)

@MdSadiqMd MdSadiqMd requested a review from snowdamiz as a code owner April 14, 2026 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: allow payload variant patterns to omit unused binders (Ok ->, Err ->)

1 participant